home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr29 / tskbar15.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1995-01-12  |  9KB  |  251 lines

  1. /* v1.05 : Taskbar program installation */
  2. SIGNAL ON SYNTAX
  3.  
  4. CALL RxFuncAdd "SysLoadFuncs","REXXUTIL","SysLoadFuncs"
  5. CALL SysLoadFuncs
  6.  
  7. PARSE ARG destDir
  8.  
  9. IF destDir="" | destDir="/?" | TRANSLATE(destDir)="HELP" | TRANSLATE(destDir)="/H" THEN
  10.     DO
  11.         SAY "Usage: INSTALL destDir"
  12.         SAY ""
  13.         SAY "       destDir     = Directory location where you want"
  14.         SAY "                     the Taskbar program installed."
  15.         EXIT
  16.     END
  17.  
  18. currentDir = DIRECTORY()
  19. CALL CheckSource currentDir
  20. destDir = CreateDestDir(destDir)
  21. if TRANSLATE(currentDir)\=TRANSLATE(destDir) THEN CALL CopyProgramFiles destDir
  22. configChanged = 0
  23. CALL UpdateLibpath destDir
  24. CALL MakeObjects destDir
  25. SAY "Program installation complete."
  26. EXIT
  27.  
  28. /***** SUBROUTINES *****/
  29.  
  30. /*****************************************************************************
  31.  * CheckSource      - makes sure that all necessary files are present
  32.  *                    in the source directory. Terminates the install
  33.  *                    script if an error occurs.
  34.  *****************************************************************************/
  35. CheckSource: PROCEDURE
  36.     PARSE ARG currentDir
  37.  
  38.     sourceList.0 = 4
  39.     sourceList.1 = 'BootDriv.exe'
  40.     sourceList.2 = 'MakeObjs.CMD'
  41.     sourceList.3 = 'TaskBar.EXE'
  42.     sourceList.4 = 'TskBarHk.DLL'
  43.  
  44.     DO n = 1 TO sourceList.0
  45.         IF STREAM(sourceList.n,"C","QUERY EXISTS")="" THEN
  46.             DO
  47.                 SAY "Unable to find file "||sourceList.n||" in "||currentDir
  48.                 EXIT
  49.             END
  50.     END
  51.     RETURN
  52. /*****************************************************************************/
  53.  
  54. /*****************************************************************************
  55.  * CreateDestDir    - procedure to create the destination directory.
  56.  *                    Returns the fully qualified pathname of the
  57.  *                    destination directory. Terminates the install script
  58.  *                    if an error occurs.
  59.  *****************************************************************************/
  60. CreateDestDir: PROCEDURE
  61.     PARSE ARG destDir
  62.  
  63.     CALL SETLOCAL
  64.     target = DIRECTORY(destDir) /* check whether dest dir exists */
  65.     IF target="" THEN /* dest dir doesn't exist so create it */
  66.         DO
  67.             IF 0\=SysMkDir(destDir) THEN
  68.                 DO
  69.                     SAY "Error creating directory '"||destDir||"'"
  70.                     EXIT
  71.                 END
  72.         END
  73.     destDir = DIRECTORY(destDir) /* get fully qualified pathname of dest dir */
  74.     CALL ENDLOCAL
  75.     RETURN destDir
  76. /*****************************************************************************/
  77.  
  78. /*****************************************************************************
  79.  * CopyProgramFiles - procedure to copy the program files to the
  80.  *                    specified directory. Terminates the install
  81.  *                    script if an error occurs.
  82.  *****************************************************************************/
  83. CopyProgramFiles: PROCEDURE
  84.     PARSE ARG destDir
  85.  
  86.     filelist.0 = 3
  87.     filelist.1 = "TaskBar.EXE"
  88.     filelist.2 = "TskBarHk.DLL"
  89.     filelist.3 = "MakeObjs.CMD"
  90.  
  91.     SAY "Copying program files to "||destDir||" ..."
  92.     DO n=1 TO filelist.0
  93.         '@COPY '||filelist.n||' '||destDir
  94.         IF rc\=0 THEN
  95.             DO
  96.                 SAY "Error copying "||filelist.n
  97.                 EXIT
  98.             END
  99.     END
  100.  
  101.     RETURN
  102. /*****************************************************************************/
  103.  
  104. /*****************************************************************************
  105.  * UpdateLibpath    - procedure to revise, if necessary, the Config.Sys
  106.  *                    LIBPATH statement. Terminates the install script
  107.  *                    if an error occurs.
  108.  *****************************************************************************/
  109. UpdateLibpath: PROCEDURE EXPOSE configChanged
  110.     PARSE ARG destDir
  111.  
  112.     SAY "Checking/revising Config.Sys ..."
  113.  
  114.     '@BOOTDRIV.EXE'
  115.     bootDrive = SUBSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ",rc,1)
  116.     configSys = bootDrive||":\Config.Sys"
  117.  
  118.     IF STREAM(configSys,"C","QUERY EXISTS")="" THEN
  119.         DO
  120.             SAY "Error: Unable to find '"||configSys||"'."
  121.             EXIT
  122.         END
  123.  
  124.     tempfile = SysTempFileName(bootDrive||":\XX????.TMP")
  125.     libpathFound = 0
  126.  
  127.     DO WHILE LINES(configSys) > 0
  128.         line = LINEIN(configSys)
  129.         sline = TRANSLATE(STRIP(line))
  130.         PARSE VAR sline first rest
  131.         first = TRANSLATE(STRIP(first))
  132.         rest = TRANSLATE(STRIP(rest))
  133.         IF LEFT(first,8) = "LIBPATH=" THEN
  134.             DO
  135.                 libpathFound=1
  136.                 line = UpdateLine(line,destDir)
  137.             END
  138.         CALL LINEOUT tempfile,line
  139.     END
  140.     CALL STREAM configSys,'C','CLOSE'
  141.     CALL STREAM tempfile,'C','CLOSE'
  142.  
  143.     IF libpathFound=0 THEN
  144.         DO
  145.             SAY "LIBPATH statement not found in Config.Sys."
  146.             CALL SysFileDelete tempfile
  147.             EXIT
  148.         END
  149.  
  150.     IF configChanged = 1 THEN
  151.         DO
  152.             backupFile = SysTempFileName( bootDrive||":\Config.???" )
  153.             IF backupFile = "" THEN
  154.                 DO
  155.                     SAY "Unable to backup existing Config.Sys."
  156.                     SAY "The updated Config.Sys is in file "||tempfile||"."
  157.                     EXIT
  158.                 END
  159.             '@COPY '||configSys||' '||backupFile
  160.             IF rc\=0 THEN
  161.                 DO
  162.                     SAY "Unable to backup existing Config.Sys."
  163.                     SAY "The updated Config.Sys is in file "||tempfile||"."
  164.                     EXIT
  165.                 END
  166.             '@COPY '||tempfile||' '||configSys
  167.             IF rc\=0 THEN
  168.                 DO
  169.                     SAY "Unable to write the updated Config.Sys."
  170.                     SAY "A backup copy of the original Config.Sys is in file "||backupFile||"."
  171.                     SAY "The updated Config.Sys is in file "||tempfile||"."
  172.                     EXIT
  173.                 END
  174.  
  175.             SAY "Your Config.Sys has been updated. Reboot before running Taskbar."
  176.         END
  177.     ELSE
  178.         DO
  179.             SAY "Your Config.Sys required no modification."
  180.         END
  181.  
  182.     CALL SysFileDelete tempfile
  183.     RETURN
  184. /*****************************************************************************/
  185.  
  186. /*****************************************************************************
  187.  * UpdateLine   - procedure to add the destination directory to the
  188.  *                specified path list.
  189.  *****************************************************************************/
  190. UpdateLine: PROCEDURE EXPOSE configChanged
  191.     PARSE ARG line destDir
  192.  
  193.     PARSE VAR line first"="rest
  194.     rest = STRIP(rest,"t")
  195.     restUpr = TRANSLATE(rest)
  196.     pgmDir = TRANSLATE(destDir)
  197.     pathFound = 0
  198.  
  199.     DO WHILE restUpr <> ""
  200.         PARSE VAR restUpr thisPath";"restUpr
  201.         IF thisPath=pgmDir | thisPath="." THEN
  202.             DO
  203.                 pathFound = 1
  204.                 LEAVE
  205.             END
  206.     END
  207.  
  208.     IF pathFound=0 THEN
  209.         DO
  210.             rest = strip(rest,'t',';')||";"||destDir||";"
  211.             configChanged = 1
  212.             line = first"="rest
  213.         END
  214.  
  215.     RETURN line
  216. /*****************************************************************************/
  217.  
  218. /*****************************************************************************
  219.  * MakeObjects  - procedure to create the necessary Workplace Shell objects.
  220.  *                Terminates the install script if an error occurs.
  221.  *****************************************************************************/
  222. MakeObjects: PROCEDURE
  223.     PARSE ARG destDir
  224.  
  225.     SAY "Creating/updating Taskbar program object."
  226.     objectSetup = "OBJECTID=<Taskbar_RFY>;EXENAME="||destDir||"\Taskbar.EXE;STARTUPDIR="||destDir
  227.     IF 0=SysCreateObject( "WPProgram","Taskbar","<WP_DESKTOP>",objectSetup,"update" ) THEN
  228.         DO
  229.             SAY "Unable to create program object."
  230.             EXIT
  231.         END
  232.  
  233.     SAY "Creating/updating shadow in startup folder."
  234.     objectSetup = "OBJECTID=<Taskbar_RFY_Shadow>;SHADOWID=<Taskbar_RFY>"
  235.     IF 0=SysCreateObject( "WPShadow","Taskbar","<WP_START>",objectSetup,"update" ) THEN
  236.         DO
  237.             SAY "Unable to create shadow object."
  238.             EXIT
  239.         END
  240.     RETURN
  241. /*****************************************************************************/
  242.  
  243. /*****************************************************************************/
  244.  * Standard REXX program error handlers
  245.  *****************************************************************************/
  246. SYNTAX:
  247.     SAY 'REXX error' rc 'in line' sigl
  248.     SAY "Instruction = "||SOURCELINE(sigl)
  249.     EXIT
  250. /*****************************************************************************/
  251.